<%--
  Created by IntelliJ IDEA.
  User: 22450
  Date: 2021/12/2
  Time: 11:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--%>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>天天生鲜-用户中心</title>
    <link rel="stylesheet" type="text/css" href="css/reset.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
    <script>
        function btnClick1(btn) {//联系方式
            var toEdit = btn.value == '编辑';
            $('#dvInput1')[toEdit ? 'removeClass' : 'addClass']('readonly').find(':input').attr('readonly', toEdit ? false : true);
            btn.value = toEdit ? '保存' : '编辑';
            if (!toEdit) {//保存的ajax代码
                var value1 = $("#value1").val();
                var value2 = $("#value2").val();
                // 使用ajax发送请求
                $.ajax({
                    url: "/UpdateUserInfServlet", // 要访问的地址，这里访问的是servlet映射地址
                    cache: false,  // 是否缓存
                    data: {"phoneNumber":value1,
                        "address":value2,
                        "name":"address"},// 相当于地址栏后面的参数
                    success: function(result){ // 访问成功后，执行的方法，参数是后台的结果
                        // 将获取到的数据写入span标签
                        // $("#sp").text(result);
                        $("#value1").text(result)
                    }
                })
            }
        }
        function btnClick2(btn) {//联系地址
            var toEdit = btn.value == '编辑';
            $('#dvInput2')[toEdit ? 'removeClass' : 'addClass']('readonly').find(':input').attr('readonly', toEdit ? false : true);
            btn.value = toEdit ? '保存' : '编辑';
            if (!toEdit) {//保存的ajax代码
                var value1 = $("#value1").val();
                var value2 = $("#value2").val();
                // 使用ajax发送请求
                $.ajax({
                    url: "/UpdateUserInfServlet", // 要访问的地址，这里访问的是servlet映射地址
                    cache: false,  // 是否缓存
                    data: {"phoneNumber":value1,
                            "address":value2,
                            "name":"address"},// 相当于地址栏后面的参数
                    success: function(result){ // 访问成功后，执行的方法，参数是后台的结果
                        // 将获取到的数据写入span标签
                        // $("#sp").text(result);
                        $("#value2").text(result)
                    }
                })
            }
        }
    </script>
    <style>.readonly input{border:none}</style>
</head>
<body>
<div class="header_con">
    <div class="header">
        <div class="welcome fl">欢迎来到天天生鲜!</div>
        <div class="fr">
            <div class="login_info fl">
                欢迎您：<em>${sessionScope.username}</em>
            </div>
            <div class="login_btn fl">
                <a href="login.jsp">登录</a>
                <span>|</span>
                <a href="register.jsp">注册</a>
            </div>
            <div class="user_link fl">
                <span>|</span>
                <a href="user_center_info.jsp">用户中心</a>
                <span>|</span>
                <a href="cart.jsp">我的购物车</a>
                <span>|</span>
                <a href="user_center_order.jsp">我的订单</a>
            </div>
        </div>
    </div>
</div>

<div class="search_bar clearfix">
    <a href="index.jsp" class="logo fl"><img src="images/logo.png"></a>
    <div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;用户中心</div>
    <div class="search_con fr">
        <input type="text" class="input_text fl" name="" placeholder="搜索商品">
        <input type="button" class="input_btn fr" name="" value="搜索">
    </div>
</div>

<div class="main_con clearfix">
    <div class="left_menu_con clearfix">
        <h3>用户中心</h3>
        <ul>
            <li><a href="user_center_info.jsp" class="active">· 个人信息</a></li>
            <li><a href="user_center_order.jsp">· 全部订单</a></li>
            <li><a href="/user_center_site.jsp">· 收货地址</a></li>
        </ul>
    </div>
    <div class="right_content clearfix">
        <div class="info_con clearfix">
            <h3 class="common_title2">基本信息</h3>
            <ul class="user_info_list">

                <li><span>用户名：</span>${sessionScope.userInfomation.username}</li>

                <li><span>联系方式：</span>
                    <div id="dvInput1" class="readonly">
                        <input type="text" id="value1" readonly value=${sessionScope.userInfomation.phoneNumber} />
                    </div>
                    <input type="button" value="编辑" onclick="btnClick1(this)" />
<%--                    ${sessionScope.userInfomation.phoneNumber}--%>
                </li>
                <li><span>联系地址：</span>
                    <div id="dvInput2" class="readonly">
                        <input type="text" id="value2" readonly value=${sessionScope.userInfomation.address} />
                    </div>
                    <input type="button" value="编辑" onclick="btnClick2(this)" />
<%--                    ${sessionScope.userInfomation.address}--%>
                </li>

            </ul>
        </div>

        <h3 class="common_title2">最近浏览</h3>
        <div class="has_view_list">
            <ul class="goods_type_list clearfix">
                <li>
                    <a href="detail.jsp"><img src="images/goods/goods003.jpg"></a>
                    <h4><a href="detail.jsp">大兴大棚草莓</a></h4>
                    <div class="operate">
                        <span class="prize">￥16.80</span>
                        <span class="unit">16.80/500g</span>
                        <a href="#" class="add_goods" title="加入购物车"></a>
                    </div>
                </li>

                <li>
                    <a href="detail.jsp"><img src="images/goods/goods004.jpg"></a>
                    <h4><a href="detail.jsp">吐鲁番梨光杏</a></h4>
                    <div class="operate">
                        <span class="prize">￥5.50</span>
                        <span class="unit">5.50/500g</span>
                        <a href="#" class="add_goods" title="加入购物车"></a>
                    </div>
                </li>

                <li>
                    <a href="detail.jsp"><img src="images/goods/goods005.jpg"></a>
                    <h4><a href="detail.jsp">黄肉桃</a></h4>
                    <div class="operate">
                        <span class="prize">￥10.00</span>
                        <span class="unit">10.00/500g</span>
                        <a href="#" class="add_goods" title="加入购物车"></a>
                    </div>
                </li>

                <li>
                    <a href="detail.jsp"><img src="images/goods/goods006.jpg"></a>
                    <h4><a href="detail.jsp">进口西梅</a></h4>
                    <div class="operate">
                        <span class="prize">￥28.80</span>
                        <span class="unit">28.8/500g</span>
                        <a href="#" class="add_goods" title="加入购物车"></a>
                    </div>
                </li>

                <li>
                    <a href="detail.jsp"><img src="images/goods/goods007.jpg"></a>
                    <h4><a href="detail.jsp">香梨</a></h4>
                    <div class="operate">
                        <span class="prize">￥6.45</span>
                        <span class="unit">6.45/500g</span>
                        <a href="#" class="add_goods" title="加入购物车"></a>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>



<div class="footer">
    <div class="foot_link">
        <a href="#">关于我们</a>
        <span>|</span>
        <a href="#">联系我们</a>
        <span>|</span>
        <a href="#">招聘人才</a>
        <span>|</span>
        <a href="#">友情链接</a>
    </div>
    <p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
    <p>电话：010-****888    京ICP备*******8号</p>
</div>

</body>
</html>